#include <Arduino.h>
#include <avr/pgmspace.h>

#include "variableDefine.h"
#include "commandFun.h"

/////////////////////////////////////////////////////////////////////////////////////////////
// 定义指令
static const char cmd_on[] = "ON";
static const char cmd_off[] = "OFF";
static const char cmd_state_req[] = "state";
static const char cmd_state_rsp[] = "STATE";
static const char cmd_restart[] = "RESTART";
static const char cmd_setip[] = "IP";
static const char cmd_setmac[] = "MAC";
static const char cmd_start[] = "START";
/////////////////////////////////////////////////////////////////////////////////////////////
// 定义指令
int command_size = 0;
command commands[] = {
    { cmd_on, strlen(cmd_on), pinon},
    { cmd_off, strlen(cmd_off), pinoff},
    { cmd_state_req, strlen(cmd_state_req), pinStateReq },
    { cmd_state_rsp, strlen(cmd_state_rsp), pinStateRsp },
    { cmd_restart, strlen(cmd_restart), restart},
    { cmd_setip, strlen(cmd_setip), setIp },
    { cmd_setmac, strlen(cmd_setmac), setMac },
    { cmd_start, strlen(cmd_start), start },
};

////////////////////////////////////////////////////////////////////////////////////////////////////
// 端口映射定义

int pin_size = 0;
portcfg pin_list[] = {
    { D0, "1", false },
    { D1, "2", false },
    { D2, "3", false },
    { D3, "4", false },
    { D4, "5", false },
    { D8, "6", false },
    { D9, "7", false },
    { D10, "8", false },
    { D11, "9", false },
    { D12, "10", false },
    //{ A0, "11", false },
    //{ A1, "12", false },
    //{ A2, "13", false },
    //{ A3, "14", false },
};

////////////////////////////////////////////////////////////////////////////////////////////////////
void variableInit() {
    command_size = sizeof(commands) / sizeof(command);
    pin_size = sizeof(pin_list) / sizeof(portcfg);
}
